package com.yuwei.bean;

import java.util.ArrayList;
import java.util.List;

public class Role {
    private String roleName;
    private String path;
    private int id;
    private String roleDes;
    private List<Role> children = new ArrayList<>();

    public List<Role> getChildren() {
        return children;
    }

    public Role() {
    }

    public Role getChildByID(int id){
        for(Role role : children){
            if(role.getId() == id){
                return role;
            }
        }
        return null;
    }

    public boolean delRoleByID(int id){
        Role child = getChildByID(id);
        if(child == null)
        {
            System.out.println(this.roleName+"没有查找到"+id);
            return true;
        }
        children.remove(child);
        return true;
    }

    public Role(String roleName, String path) {
        this.roleName = roleName;
        this.path = path;
    }

    public Role addRole(Role role){
        if(children.contains(role))
            return role;
        children.add(role);
        return role;
    }

    public String getRoleDes() {
        return roleDes;
    }

    public void setRoleDes(String roleDes) {
        this.roleDes = roleDes;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
}
